#!/bin/bash
# Based By: https://github.com/UserUnavailable
# Modified By: https://notabug.org/mhf/Dotfiles

ICON=siji
BOLD="Input Mono Condensed:style=Bold:pixelsize=10"

Artist() {
	title=$(cmus-remote -C 'format_print "%a"')
	title_lenght=$(echo $title | wc -c)
	if [ "$title_lenght" -gt 25 ];then
		echo $title | head -c24 | sed 's/ $//;s/$/.../'
	else
		echo $title
	fi
}

Music() {
	title=$(cmus-remote -C 'format_print "%t"')
	title_lenght=$(echo $title | wc -c)
	if [ "$title_lenght" -gt 25 ];then
		echo $title | head -c24 | sed 's/ $//;s/$/.../'
	else
		echo $title
	fi
}

# botões do player
player="^ca(1,cmus-remote --prev)^fn($ICON)$(printf '\ue097')^ca()^fn($BOLD) ^ca(1, cmus-remote --pause)^fn($ICON)$(printf '\ue09a')^ca()^fn($BOLD) ^ca(1, cmus-remote --stop)^fn($ICON)$(printf '\ue099')^ca()^fn($BOLD) ^ca(1, cmus-remote --next)^fn($ICON)$(printf '\ue05b')^ca()"

while true; do
echo "
^p(88)^fg(#3676e8)^fn($BOLD)CMUS^fg()

^p(25)^fg(#2f343f)$(Artist)^fg()
^p(25)^fg(#2f343f)$(Music)^fg()

^p(55)$player
"
sleep 1
done | dzen2 -l 7 -fg "#2f343f" -bg "#e7e8eb" -fn "Input Mono Condensed:pixelsize=10" -x 30 -y 930 -w 200 -p -sa l -e 'onstart=uncollapse;button3=exit;'
